package apiday03.homework;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

public class MapDemo3 {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        map.put("语文",99);
        map.put("数学",95);
        map.put("物理",85);
        map.put("政治",88);
        map.put("英语",68);
        System.out.println(map);

        //遍历键
        Set<String> keySet = map.keySet();
        keySet.forEach(key-> System.out.println(key));
        //遍历值
        Collection<Integer> values = map.values();
        values.forEach(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) {
                System.out.println(integer);
            }
        });
        //遍历键值对
        map.forEach((key,value)-> System.out.println(key+","+value));


    }
}
